﻿using System;
using System.Collections.Generic;
using BizElements.Core;

namespace BizElements.BusinessLayer
{
    /// <summary>Simple entity that can perform basic validation but lacks data-access and advanced business logic like security checks logic. Typically managed by another strong domain objects such as <see cref="IBusinessObject"/> business objects.</summary>
    public interface IDataObject : ISelfValidatingObject, IEntity
    {
        /// <summary>A dictionary to which values of change tracking properties are stored immediately after an object has been fetched or saved.
        /// Used by optimistic offline concurrency control scheme to check if another user or process has changed the object.
        /// Empty if optimistic offline locking is not used, i.e. if tracking properties are not defined in object's descriptor.</summary>
        IDictionary<string, object> ChangeTrackingPropertyValues { get; }

        /// <summary>Gets the value which indicates whether the entity is new or existing, ie. retrieved from database.</summary>
        bool IsNew { get; }

        /// <summary>Sets optional system fields which trace who and when created or modified the entity.</summary>
        /// <param name="createdOrModifiedBy">An actor which created or modified the object.</param>
        void SetModifiedBy(IActor createdOrModifiedBy);

        /// <summary>Gets object that contains information about weak entity structure, i.e. special fields, and field acces permissions.</summary>
        /// <returns>Weak entity descriptor.</returns>
        IDataObjectDescriptor GetDataObjectDescriptor();
    }
}